package org.lock.spring.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.lock.spring.exception.GetLockFailException;
import org.lock.spring.exception.GetLockTimeOutException;
import org.lock.spring.exception.ReleaseLockException;
/**
 * Supported SpringEL like "BUS-CREDIT-APPLY-GROUP=#{#params[0].customerId+'_'+#params[0].productId}"<br>
 * embedded the variable "params" or "root" point to the method parameters only<br>
 * <b>maybe throw exceptions, see below</b>
 * @author hank.liu
 * @see GetLockTimeOutException
 * @see GetLockFailException
 * @see ReleaseLockException
 */
@Target({ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Documented
public @interface Lock {
	
	/**
	 * lock name
	 * @return
	 */
	String name() default "";
	
	/**
	 * waitting to get lock time out, time unit is millsecond, default 100
	 * @return
	 */
	long waitTimeout() default 500;
	
}
